package com.spider.silence.utils;

import com.spider.silence.constant.Constant;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by XMX on 2016/12/23.
 */
public class ChromeDriverUtils {
    /**
     * @author 夏茂轩
     * @date 2017/1/15 22:35
     * @description 获取格式化完成后的ChromeDriver实例
     * @return org.openqa.selenium.chrome.ChromeDriver
     */
    public static ChromeDriver getDriver(){
        ChromeDriver driver= null;
       /* Map<String, Object> deviceMetrics = new HashMap<String, Object>();
        deviceMetrics.put("width", 1800);
        deviceMetrics.put("height", 4800);
        Map<String, Object> mobileEmulation = new HashMap<String, Object>();
        mobileEmulation.put("deviceMetrics", deviceMetrics);
        mobileEmulation.put("userAgent", Constant.HTTP_USER_AGENT);
        Map<String, Object> chromeOptions = new HashMap<String, Object>();
        chromeOptions.put("mobileEmulation", mobileEmulation);
        DesiredCapabilities capabilities = DesiredCapabilities.chrome();*/
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--user-agent="+Constant.HTTP_USER_AGENT);
        options.addArguments("no-sandbox");
        options.addArguments("disable-extensions");
        options.addArguments("--start-maximized");
        driver = new ChromeDriver(options);
        return  driver;
    }
}
